﻿Option Explicit On
Option Strict On

Imports NGridDrawer.Report.Layout


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'CustomersDataSet.Customers2' table. 
        'You can move, or remove it, as needed.
        Me.Customers2TableAdapter.Fill(Me.CustomersDataSet.Customers2)

        chkCenter.Checked = gridDrawer.MustCenterHorizontally
        chkFitColumns.Checked = gridDrawer.MustFitColumnsToBounds
        chkSelectedRows.Checked = gridDrawer.MustPrintSelectedRows

        If gridDrawer.PrintOrder = NGridDrawer.Partitions.PartitionOrder.OrderByLevelFirst Then
            chkLevelByLevel.Checked = True
        Else
            chkLevelByLevel.Checked = False
        End If

        reportDrawer.Title = New BlockTitle("Document Report")
        reportDrawer.Header = New BlockHeader()
        reportDrawer.Footer = New BlockFooter()


        printPreviewDialog.WindowState = FormWindowState.Maximized






    End Sub

    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
        If printDialog.ShowDialog(Me) = DialogResult.OK Then
            printDocument.Print()
        End If
    End Sub

    Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
        If printDialog.ShowDialog(Me) = DialogResult.OK Then
            printPreviewDialog.ShowDialog(Me)
        End If
    End Sub

    Private Sub chkCenter_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCenter.CheckedChanged
        gridDrawer.MustCenterHorizontally = chkCenter.Checked
    End Sub

    Private Sub chkFitColumns_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkFitColumns.CheckedChanged
        gridDrawer.MustFitColumnsToBounds = chkFitColumns.Checked
    End Sub

    Private Sub chkLevelByLevel_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkLevelByLevel.CheckedChanged
        If chkLevelByLevel.Checked Then
            gridDrawer.PrintOrder = Partitions.PartitionOrder.OrderByLevelFirst
        Else
            gridDrawer.PrintOrder = Partitions.PartitionOrder.OrderByColumnFirst
        End If
    End Sub

    Private Sub chkSelectedRows_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkSelectedRows.CheckedChanged
        gridDrawer.MustPrintSelectedRows = chkSelectedRows.Checked
    End Sub
End Class
